/*
 * Project: Daycare Web Application
 * Package: com.madetoordersoftware.daycare.control
 * File:    FormListCtrl
 * Created: Jan 17, 2014
 */
/**
 * Copyright (c) 2010 Made 2 Order Software, LLC
 *
 * All rights reserved. No part of this software may be reproduced, stored in a retrieval system, or
 * transmitted in any form or by any means, without the prior written permission of Made 2 Order Software.
 *
 * You may not distribute the URL or redistribute the files to third parties. You may transfer the files onto
 * a single storage device so long as you can prove ownership of the software. You may not reverse engineer,
 * decompile, or disassemble the software or media files. You may not modify or translate the software or
 * media, or distribute copies of the software or media without the written consent of Made 2 Order Software,
 * LLC.
 */
package com.made2ordersoftware.daycare.control;

import com.made2ordersoftware.daycare.service.ChildDao;
import com.made2ordersoftware.daycare.service.ParentDao;
import com.made2ordersoftware.daycare.service.TimeWatchedDao;
import com.made2ordersoftware.exceptions.DAOException;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author David Canning <dcannin@gmail.com>
 */
@Named("formList")
@RequestScoped
public class FormListCtrl {

    private static final Logger LOG = LoggerFactory.getLogger(FormListCtrl.class);
    private List<Long> parentIDs;
    private List<Long> childrenIDs;
    private List<Long> childrenSignedIn;
    private List<Long> usersSignedIn;
    private List<Long> myChildrenIDs;
    @EJB private TimeWatchedDao t_dao;
    @EJB private ParentDao p_dao;
    @EJB private ChildDao c_dao;

    /**
     * Creates an instance of <code>FormListCtrl</code>.
     */
    public FormListCtrl() {
    }

    /**
     * Gets a list of all parent id from the system.
     *
     * @return the parentIDs
     */
    public List<Long> getParentIDs() {
        LOG.info("Getting list of child IDs.");
        List<Long> IDs = null;
        try {
            IDs = p_dao.findParentIDs();
        } catch (DAOException e) {
            //Left empty as to just return no list.
        }
        LOG.info("Getting list of IDs successful.");
        return IDs;
    }

    /**
     * Gets a list of all children id from the system.
     *
     * @return the childrenIDs
     */
    public List<Long> getChildrenIDs() {
        LOG.info("Getting list of child IDs.");
        List<Long> IDs = null;
        try {
            IDs = c_dao.findChildIDs();
        } catch (DAOException e) {
            //Left empty as to just return no list.
        }
        LOG.info("Getting list of IDs successful.");
        return IDs;
    }

    /**
     * Gets a list of all children ids of this parent from the system.
     *
     * @param parentId The parent id you want to find children of.
     *
     * @return the parentIDs
     */
    public List<Long> getMyChildrenIDs(Long parentId) {
        LOG.info("Getting list of this parent's child IDs.");
        List<Long> IDs = null;
        try {
            IDs = p_dao.findChildIDsByParent(parentId);
        } catch (DAOException e) {
            //Left empty as to just return no list.
        }
        LOG.info("Getting list of IDs successful.");
        return IDs;
    }

    /**
     * Gets a list of all parent ids of this child from the system.
     *
     * @param childId The child id you want to find the parents of.
     *
     * @return the childIDs
     */
    public List<Long> getMyParentsIDs(Long childId) {
        LOG.info("Getting list of this child's parent IDs.");
        List<Long> IDs = null;
        try {
            IDs = c_dao.findParentIDsByChild(childId);
        } catch (DAOException e) {
            //Left empty as to just return no list.
        }
        LOG.info("Getting list of IDs successful.");
        return IDs;
    }

    /**
     * Gets a list of all children signed into the system.
     *
     * @return the childrenSignedIn
     */
    public List<Long> getChildrenSignedIn() {
        LOG.info("Getting list of child IDs.");
        List<Long> IDs = null;
        try {
            IDs = t_dao.findChildrenSignedIn();
        } catch (DAOException e) {
            //Left empty as to just return no list.
        }
        LOG.info("Getting list of IDs successful.");
        return IDs;
    }

}
